package com.example.myapplication;

import android.content.Intent;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;

import java.util.ArrayList;

public class LevelsActivity extends Activity implements View.OnClickListener {
     private ArrayList<Button>buttons=new ArrayList<Button>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_levels);

        this.buttons.add((Button)findViewById(R.id.level0_button));
        this.buttons.add((Button)findViewById(R.id.level1_button));
        this.buttons.add((Button)findViewById(R.id.level2_button));
        this.buttons.add((Button)findViewById(R.id.level3_button));
        this.buttons.add((Button)findViewById(R.id.level4_button));
        this.buttons.add((Button)findViewById(R.id.level5_button));
        this.buttons.add((Button)findViewById(R.id.level6_button));
        this.buttons.add((Button)findViewById(R.id.level7_button));
        for(int i=0; i<this.buttons.size(); i++) {
            buttons.get(i).setOnClickListener(this);
        }

    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }


    public void onClick(View v) {
        int level = 7;
        if(v.getId()==R.id.level0_button) {
                level = 0;
        }

        if(v.getId()==R.id.level1_button) {
            level = 1;
        }
        if(v.getId()==R.id.level2_button) {
            level = 2;
        }
        if(v.getId()==R.id.level3_button) {
            level = 3;
        }
        if(v.getId()==R.id.level4_button) {
            level = 4;
        }
        if(v.getId()==R.id.level5_button) {
            level = 5;
        }
        if(v.getId()==R.id.level6_button) {
            level = 6;
        }
        if(v.getId()==R.id.level7_button) {
            level = 7;
        }

        Intent intent = new Intent(LevelsActivity.this, WarsActivity.class);
        intent.putExtra("level", level);
        startActivity(intent);
    }


}
